package com.ruoyi.Newstudent.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.Newstudent.domain.Newstudent;
import com.ruoyi.Newstudent.service.INewstudentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 新生信息Controller
 * 
 * @author yjh
 * @date 2024-08-26
 */
@RestController
@RequestMapping("/Newstudent/Newstudent")
public class NewstudentController extends BaseController
{
    @Autowired
    private INewstudentService newstudentService;

    /**
     * 查询新生信息列表
     */
    @PreAuthorize("@ss.hasPermi('Newstudent:Newstudent:list')")
    @GetMapping("/list")
    public TableDataInfo list(Newstudent newstudent)
    {
        startPage();
        List<Newstudent> list = newstudentService.selectNewstudentList(newstudent);
        return getDataTable(list);
    }

    /**
     * 导出新生信息列表
     */
    @PreAuthorize("@ss.hasPermi('Newstudent:Newstudent:export')")
    @Log(title = "新生信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Newstudent newstudent)
    {
        List<Newstudent> list = newstudentService.selectNewstudentList(newstudent);
        ExcelUtil<Newstudent> util = new ExcelUtil<Newstudent>(Newstudent.class);
        util.exportExcel(response, list, "新生信息数据");
    }

    /**
     * 获取新生信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('Newstudent:Newstudent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(newstudentService.selectNewstudentById(id));
    }

    /**
     * 新增新生信息
     */
    @PreAuthorize("@ss.hasPermi('Newstudent:Newstudent:add')")
    @Log(title = "新生信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Newstudent newstudent)
    {
        return toAjax(newstudentService.insertNewstudent(newstudent));
    }

    /**
     * 修改新生信息
     */
    @PreAuthorize("@ss.hasPermi('Newstudent:Newstudent:edit')")
    @Log(title = "新生信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Newstudent newstudent)
    {
        return toAjax(newstudentService.updateNewstudent(newstudent));
    }

    /**
     * 删除新生信息
     */
    @PreAuthorize("@ss.hasPermi('Newstudent:Newstudent:remove')")
    @Log(title = "新生信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(newstudentService.deleteNewstudentByIds(ids));
    }
}
